var {RSAKey} = require("node-jsencrypt")
var CryptoJS = require("crypto-js")

var quanju = {
    $_EIk: {
        // "gt": "019924a82c70bb123aae90d483087f94",
        // "challenge": "02f4e66920d284301e69e4e615daf1a9",
        "offline": false,
        "new_captcha": true,
        "product": "float",
        "width": "300px",
        "https": true,
        "api_server": "apiv6.geetest.com",
        "protocol": "https://",
        "type": "fullpage",
        "static_servers": [
            "static.geetest.com/",
            "dn-staticdown.qbox.me/"
        ],
        "beeline": "/static/js/beeline.1.0.1.js",
        "voice": "/static/js/voice.1.2.3.js",
        "click": "/static/js/click.3.0.9.js",
        "fullpage": "/static/js/fullpage.9.1.4.js",
        "slide": "/static/js/slide.7.9.0.js",
        "geetest": "/static/js/geetest.6.0.9.js",
        "aspect_radio": {
            "slide": 103,
            "click": 128,
            "voice": 128,
            "beeline": 50
        },
    },
    $_EJi: {}
}


function haha(gt, challenge) {
    var t = quanju;
    t['$_EJi']['gt'] = gt;
    t['$_EJi']['challenge'] = challenge;

    // , n = t['$_EIk'];
    // if (!n['gt'] || !n['challenge'])
    //     return U(j('config_lack', t));
    var e = $_BIBF();
    // t['$_CCGM'] = e,
    t['$_EJi']['cc'] = 12,
        t['$_EJi']['ww'] = true,
        t['$_EJi']['i'] = e;
    var r = $_CCHF()
        , o = encrypt1(JSON['stringify'](t['$_EJi']), $_CCIl())
        , i = $_HEf(o)
        , s = {
        "\u0067\u0074": t['$_EJi']['gt'],
        "\u0063\u0068\u0061\u006c\u006c\u0065\u006e\u0067\u0065": t['$_EJi']['challenge'],
        "\u006c\u0061\u006e\u0067": "zh-cn",
        "\u0070\u0074": 0,
        "\u0063\u006c\u0069\u0065\u006e\u0074\u005f\u0074\u0079\u0070\u0065": 'web',
        "\u0077": i + r
    };
    return {
        "msg": s,
        "aeskey": $_CCIl(),
        "finger_print": e
    };
}
function $_HEf(e) {
    var t = $_HCh(e);
    return t['res'] + t['end'];
}

function $_HCh(e, o) {

    var i = this;
    o || (o = i);
    for (var t = function (e, t) {
        for (var n = 0, r = 24 - 1; 0 <= r; r -= 1)
            1 === $_HBw(t, r) && (n = (n << 1) + $_HBw(e, r));
        return n;
    }, n = '', r = '', s = e['length'], a = 0; a < s; a += 3) {
        var c;
        if (a + 2 < s)
            c = (e[a] << 16) + (e[a + 1] << 8) + e[a + 2],
                n += $_GJz(t(c, 7274496)) + $_GJz(t(c, 9483264)) + $_GJz(t(c, 19220)) + $_GJz(t(c, 235));
        else {
            var _ = s % 3;
            2 == _ ? (c = (e[a] << 16) + (e[a + 1] << 8),
                n += $_GJz(t(c, 7274496)) + $_GJz(t(c, 9483264)) + $_GJz(t(c, 19220)),
                r = '.') : 1 == _ && (c = e[a] << 16,
                n += $_GJz(t(c, 7274496)) + $_GJz(t(c, 9483264)),
                r = '.' + '.');
        }
    }
    return {
        "\u0072\u0065\u0073": n,
        "\u0065\u006e\u0064": r
    };
}

function $_HBw(e, t) {
    return e >> t & 1;
}

function $_GJz(e) {
    var t = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()';
    return e < 0 || e >= t['length'] ? '.' : t['charAt'](e);
}


function encrypt1(e, t, n) {

    // t = u['parse'](t),
    // n && n['iv'] || ((n = n || {})['iv'] = u['parse']('0000000000000000'));
    // var r = m['encrypt'](_, e, t, n);
    // var o = r['ciphertext']['words'];
    // var i = r['ciphertext']['sigBytes']``;
    // var s = [];
    //
    // for (var a = 0; a < i; a++) {
    //     var c = o[a >>> 2] >>> 24 - a % 4 * 8 & 255;
    //     s['push'](c);
    // }
    // return s;

    var key = t;
    var iv = "0000000000000000";
    key = CryptoJS.enc.Utf8.parse(key);
    iv = CryptoJS.enc.Utf8.parse(iv);

    var r = CryptoJS.AES.encrypt(e, key, {
        iv: iv,
        mode: CryptoJS.mode.CBC
    });

    var o = r['ciphertext']['words'];
    var i = r['ciphertext']['sigBytes'];
    var a = [];
    for (var s = 0; s < i; s++) {
        var c = o[s >>> 2] >>> 24 - s % 4 * 8 & 255;
        a['push'](c);
    }
    return a;


}

function $_CCHF(e) {
    var rsa = new RSAKey();
    rsa.setPublic('00C1E3934D1614465B33053E7F48EE4EC87B14B95EF88947713D25EECBFF7E74C7977D02DC1D9451F79DD5D1C10C29ACB6A9B4D6FB7D0A0279B6719E1772565F09AF627715919221AEF91899CAE08C0D686D748B20A3603BE2318CA6BC2B59706592A9219D0BF05C9F65023A21D2330807252AE0066D59CEEFA5F2748EA80BAB81', '10001');
    // var t = new X()['encrypt'](this['$_CCIl'](e));
    var t = rsa ['encrypt']($_CCIl(e));
    while (!t || 256 !== t['length'])
        t = new X()['encrypt']($_CCIl(!0));
    return t;
}

// function X() {
//
//     this['n'] = null,
//     this['e'] = 0,
//     this['d'] = null,
//     this['p'] = null,
//     this['q'] = null,
//     this['dmq1'] = null,
//     this['dmq1'] = null,
//     this['coeff'] = null;
//     this['setPublic']('00C1E3934D1614465B33053E7F48EE4EC87B14B95EF88947713D25EECBFF7E74C7977D02DC1D9451F79DD5D1C10C29ACB6A9B4D6FB7D0A0279B6719E1772565F09AF627715919221AEF91899CAE08C0D686D748B20A3603BE2318CA6BC2B59706592A9219D0BF05C9F65023A21D2330807252AE0066D59CEEFA5F2748EA80BAB81', '10001');
//     // $_DDJIS = VIPVz.$_Ds()[0][13];
//
// }
// function $_CCIl(e) {
//     return this['$_EIk']['aeskey'] && !e || (this['$_EIk']['aeskey'] = te()),
//     this['$_EIk']['aeskey'];
// }


function $_CCIl(e) {
    return quanju['$_EIk']['aeskey'] && !e || (quanju['$_EIk']['aeskey'] = te()),
        quanju['$_EIk']['aeskey'];
}

function te() {
    return e() + e() + e() + e();
}

function e() {
    return (65536 * (1 + Math['random']()) | 0)['toString'](16)['substring'](1);
}

function $_BIBF() {

    var n = this,
        r = {
            "STYLE": 1,
            "SCRIPT": 5,
            "A": 1,
            "DIV": 12,
            "LABEL": 3,
            "INPUT": 2,
            "textLength": 6148,
            "HTMLLength": 7436,
            "documentMode": "CSS1Compat",
            "browserLanguage": "zh-CN",
            "browserLanguages": "zh-CN,zh",
            "devicePixelRatio": 1.25,
            "colorDepth": 24,
            "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
            "cookieEnabled": 1,
            "netEnabled": 1,
            "innerWidth": 407,
            "innerHeight": 1035,
            "outerWidth": 2048,
            "outerHeight": 1112,
            "screenWidth": 2048,
            "screenHeight": 1152,
            "screenAvailWidth": 2048,
            "screenAvailHeight": 1112,
            "screenLeft": 0,
            "screenTop": 0,
            "screenAvailLeft": 0,
            "screenAvailTop": 0,
            "localStorageEnabled": 1,
            "sessionStorageEnabled": 1,
            "indexedDBEnabled": 1,
            "platform": "Win32",
            "doNotTrack": 0,
            "timezone": -8,
            "canvas2DFP": "e400ad0142bd9ab051382005a846760d",
            "canvas3DFP": 0,
            "plugins": "internal-pdf-viewer,internal-pdf-viewer,internal-pdf-viewer,internal-pdf-viewer,internal-pdf-viewer",
            "maxTouchPoints": 0,
            "flashEnabled": -1,
            "javaEnabled": 0,
            "hardwareConcurrency": 12,
            "jsFonts": "Arial,ArialBlack,ArialNarrow,BookAntiqua,BookmanOldStyle,Calibri,Cambria,CambriaMath,Century,CenturyGothic,CenturySchoolbook,ComicSansMS,Consolas,Courier,CourierNew,Garamond,Georgia,Helvetica,Impact,LucidaBright,LucidaCalligraphy,LucidaConsole,LucidaFax,LucidaHandwriting,LucidaSans,LucidaSansTypewriter,LucidaSansUnicode,MicrosoftSansSerif,MonotypeCorsiva,MSGothic,MSPGothic,MSReferenceSansSerif,MSSansSerif,MSSerif,PalatinoLinotype,SegoePrint,SegoeScript,SegoeUI,SegoeUILight,SegoeUISemibold,SegoeUISymbol,Tahoma,Times,TimesNewRoman,TrebuchetMS,Verdana,Wingdings,Wingdings2,Wingdings3",
            "mediaDevices": -1,
            "timestamp": 1689938491363,
            "touchEvent": -1,
            "performanceTiming": -1,
            "internalip": -1
        },
        arr = [
            "textLength",
            "HTMLLength",
            "documentMode",
            "A",
            "ARTICLE",
            "ASIDE",
            "AUDIO",
            "BASE",
            "BUTTON",
            "CANVAS",
            "CODE",
            "IFRAME",
            "IMG",
            "INPUT",
            "LABEL",
            "LINK",
            "NAV",
            "OBJECT",
            "OL",
            "PICTURE",
            "PRE",
            "SECTION",
            "SELECT",
            "SOURCE",
            "SPAN",
            "STYLE",
            "TABLE",
            "TEXTAREA",
            "VIDEO",
            "screenLeft",
            "screenTop",
            "screenAvailLeft",
            "screenAvailTop",
            "innerWidth",
            "innerHeight",
            "outerWidth",
            "outerHeight",
            "browserLanguage",
            "browserLanguages",
            "systemLanguage",
            "devicePixelRatio",
            "colorDepth",
            "userAgent",
            "cookieEnabled",
            "netEnabled",
            "screenWidth",
            "screenHeight",
            "screenAvailWidth",
            "screenAvailHeight",
            "localStorageEnabled",
            "sessionStorageEnabled",
            "indexedDBEnabled",
            "CPUClass",
            "platform",
            "doNotTrack",
            "timezone",
            "canvas2DFP",
            "canvas3DFP",
            "plugins",
            "maxTouchPoints",
            "flashEnabled",
            "javaEnabled",
            "hardwareConcurrency",
            "jsFonts",
            "timestamp",
            "performanceTiming",
            "internalip",
            "mediaDevices",
            "DIV",
            "P",
            "UL",
            "LI",
            "SCRIPT",
            "touchEvent"
        ];
    r['timestamp'] = new Date()['getTime'](),
        r['touchEvent'] = -1,
        r['performanceTiming'] = -1,
        r['internalip'] = -1;
    var o = [];
    return new ce(arr)['$_EAz'](function (e) {

        var t = r[e];
        o['push'](0 === t ? -1 : t);
    }),
        o['join']('!!');
}


function ce(e) {
    this['$_BAEJ'] = e || [];
}

ce['prototype'] = {
    "\u0024\u005f\u0048\u004a\u006d": function (e) {
        return this['$_BAEJ'][e];
    },
    "\u0024\u005f\u0042\u0041\u0047\u0078": function () {
        return this['$_BAEJ']['length'];
    },
    "\u0024\u005f\u0044\u004a\u0064": function (e, t) {
        return new ce(K(t) ? this['$_BAEJ']['slice'](e, t) : this['$_BAEJ']['slice'](e));
    },
    "\u0024\u005f\u0042\u0041\u0048\u0055": function (e) {

        return this['$_BAEJ']['push'](e),
            this;
    },
    "\u0024\u005f\u0042\u0041\u0049\u0054": function (e, t) {

        return this['$_BAEJ']['splice'](e, t || 1);
    },
    "\u0024\u005f\u0045\u0042\u0078": function (e) {

        return this['$_BAEJ']['join'](e);
    },
    "\u0024\u005f\u0042\u0041\u004a\u0051": function (e) {

        return new ce(this['$_BAEJ']['concat'](e));
    },
    "\u0024\u005f\u0045\u0041\u007a": function (e) {

        var t = this['$_BAEJ'];
        if (t['map'])
            return new ce(t['map'](e));
        for (var n = [], r = 0, o = t['length']; r < o; r += 1)
            n[r] = e(t[r], r, this);
        return new ce(n);
    },
    "\u0024\u005f\u0042\u0042\u0041\u0068": function (e) {

        var t = this['$_BAEJ'];
        if (t['filter'])
            return new ce(t['filter'](e));
        for (var n = [], r = 0, o = t['length']; r < o; r += 1)
            e(t[r], r, this) && n['push'](t[r]);
        return new ce(n);
    },
    "\u0024\u005f\u0045\u0048\u0063": function (e) {

        var t = this['$_BAEJ'];
        if (t['indexOf'])
            return t['indexOf'](e);
        for (var n = 0, r = t['length']; n < r; n += 1)
            if (t[n] === e)
                return n;
        return -1;
    },
    "\u0024\u005f\u0042\u0042\u0042\u0072": function (e) {

        var t = this['$_BAEJ'];
        if (!t[aling(655)])
            for (var n = arguments[1], r = 0; r < t['length']; r++)
                r in t && e['call'](n, t[r], r, this);
        return t['forEach'](e);
    }
}


// console.log($_CCHF())
// console.log(quanju.$_EIk)
console.log(haha("019924a82c70bb123aae90d483087f94", "02f4e66920d284301e69e4e615daf1a9"))
